package com.bigboy.bbs.util;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

import com.oreilly.servlet.multipart.FileRenamePolicy;

public class RenameFile implements FileRenamePolicy {

	public File rename(File file) {
		String name = file.getName();
		String ext = name.substring(name.lastIndexOf("."));
		String newName = new SimpleDateFormat("yyyyMMddHHmmssms").format(new Date())+new Random().nextInt(1000);
		newName = newName +ext;
		return new File(file.getParent(), newName);
	}

}
